load("//:build_variables.bzl", "COPTS")
load("//tools/lint:linters.bzl", "clang_tidy_test")

package(
    default_visibility = ["//:android_cuttlefish"],
)

cc_library(
    name = "parser",
    srcs = [
        "arguments_separator.cpp",
        "creation_analyzer.cpp",
        "device_selector_utils.cpp",
        "selector_common_parser.cpp",
        "selector_option_parser_utils.cpp",
        "start_selector_parser.cpp",
    ],
    hdrs = [
        "arguments_separator.h",
        "creation_analyzer.h",
        "device_selector_utils.h",
        "selector_common_parser.h",
        "selector_constants.h",
        "selector_option_parser_utils.h",
        "start_selector_parser.h",
    ],
    deps = [
        "//cuttlefish/common/libs/utils:contains",
        "//cuttlefish/common/libs/utils:files",
        "//cuttlefish/common/libs/utils:flag_parser",
        "//cuttlefish/common/libs/utils:result",
        "//cuttlefish/common/libs/utils:unique_resource_allocator",
        "//cuttlefish/common/libs/utils:users",
        "//cuttlefish/host/commands/cvd/cli:types",
        "//cuttlefish/host/commands/cvd/instances/lock",
        "//cuttlefish/host/commands/cvd/instances:cvd_persistent_data",
        "//cuttlefish/host/commands/cvd/instances:device_name",
        "//cuttlefish/host/commands/cvd/utils",
        "//cuttlefish/host/libs/config:config_constants",
        "//cuttlefish/host/libs/config:instance_nums",
        "//libbase",
    ],
)

clang_tidy_test(
    name = "parser_clang_tidy",
    srcs = [":parser"],
    tags = ["clang_tidy", "clang-tidy"],
)

cc_library(
    name = "selector",
    srcs = ["selector.cpp"],
    hdrs = ["selector.h"],
    deps = [
        ":parser",
        "//cuttlefish/common/libs/utils:result",
        "//cuttlefish/common/libs/utils:users",
        "//cuttlefish/host/commands/cvd/cli:command_request",
        "//cuttlefish/host/commands/cvd/cli:interruptible_terminal",
        "//cuttlefish/host/commands/cvd/cli:utils",
        "//cuttlefish/host/commands/cvd/instances",
        "//cuttlefish/host/libs/config:config_constants",
        "//libbase",
    ],
)

clang_tidy_test(
    name = "selector_clang_tidy",
    srcs = [":selector"],
    tags = ["clang_tidy", "clang-tidy"],
)

cc_test(
    name = "selector_test",
    srcs = [
        "group_record_test.cpp",
        "host_tool_target_test.cpp",
        "instance_database_helper.cpp",
        "instance_database_helper.h",
        "instance_database_test.cpp",
        "instance_record_test.cpp",
        "parser_ids_helper.cpp",
        "parser_ids_helper.h",
        "parser_ids_test.cpp",
        "parser_names_helper.cpp",
        "parser_names_helper.h",
        "parser_names_test.cpp",
    ],
    copts = COPTS + [ "-Icuttlefish" ],
    deps = [
        "//cuttlefish/common/libs/fs",
        "//cuttlefish/common/libs/utils:environment",
        "//cuttlefish/common/libs/utils:files",
        "//cuttlefish/common/libs/utils:json",
        "//cuttlefish/common/libs/utils:result_matchers",
        "//cuttlefish/host/commands/cvd/cli/commands:host_tool_target",
        "//cuttlefish/host/commands/cvd/instances:cvd_persistent_data",
        "//cuttlefish/host/commands/cvd/instances",
        "//cuttlefish/host/commands/cvd/cli:types",
        "//cuttlefish/host/commands/cvd/cli/selector:parser",
        "//cuttlefish/host/libs/config:config_constants",
        "//libbase",
        "@googletest//:gtest",
        "@googletest//:gtest_main",
    ],
)

clang_tidy_test(
    name = "selector_test_clang_tidy",
    srcs = [":selector_test"],
    tags = ["clang_tidy", "clang-tidy"],
)
